﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CC.Common
{
    /// <summary>
    /// 替换System.Drawing.PointF
    /// </summary>
    public struct Point32
    {
        //
        // 摘要:
        //     Represents a new instance of the System.Drawing.PointF class with member data
        //     left uninitialized.
        public static readonly Point32 Empty = new Point32(0, 0);


        public float X;
        public float Y;
        public Point32(float x, float y)
        {
            X = x;
            Y = y;
        }
        public Point32(double x, double y)
        {
           X = (float)x;
            Y = (float)y;
        }
       


        //
        // 摘要:
        //     Gets a value indicating whether this System.Drawing.PointF is empty.
        //
        // 返回结果:
        //     true if both System.Drawing.PointF.X and System.Drawing.PointF.Y are 0; otherwise,
        //     false.
        public bool IsEmpty { get { return X == 0 && Y == 0; } }
        public override int GetHashCode()
        {
            return base.GetHashCode();
        }
        //
        // 摘要:
        //     Specifies whether this System.Drawing.PointF contains the same coordinates as
        //     the specified System.Object.
        //
        // 参数:
        //   obj:
        //     The System.Object to test.
        //
        // 返回结果:
        //     This method returns true if obj is a System.Drawing.PointF and has the same coordinates
        //     as this System.Drawing.Point.
        public override bool Equals(object obj)
        {
            if(obj.GetType()==typeof(Point32))
            {
                return this == (Point32)obj;
            }
            else
            {
                return false;
            }
        }
      
        public override string ToString()
        {
            return $"{X}, {Y}";
        }
        public  string ToString(char splitor = ',')
        {
            return $"{X}{splitor} {Y}";
        }
       
        public static bool operator ==(Point32 left, Point32 right)
        {
            return left.X == right.X && left.Y == right.Y;
        }
        
        public static bool operator !=(Point32 left, Point32 right)
        {
            return left.X != right.X || left.Y != right.Y;
        }
        

    }
}
